﻿package fwk.form.elements 
{
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.MouseEvent;

	
	public class AbstractReponse extends MovieClip
	{
		
		public var abstractReponse:AbstractReponse;
		
		public var mc:MovieClip;
		public var id:String;
		public var value:String;
		public var valueInitial:String;
		public var type:String;
		public var selected:Boolean = false;
		
		private var _clipMouseDown:MovieClip;
		
		protected var _rollOver:Boolean = false;
		private var _spriteFocus:Sprite;
		private var _colorShapeFocus:int;
		private var _shapeFocus:Boolean = false;
		
		public function set clipMouseDown(val:MovieClip)
		{
			_clipMouseDown = val;
			_clipMouseDown.abstractReponse 		= this;

			
		}
		public function get clipMouseDown():MovieClip
		{
			return _clipMouseDown;
			
		}
		
		public function get spriteFocus():Sprite { return _spriteFocus; }
		
		public function get colorShapeFocus():int { return _colorShapeFocus; }
		
		public function set colorShapeFocus(value:int):void 
		{
			_colorShapeFocus = value;
		}

		
		
		public function AbstractReponse(mc:MovieClip = null)
		{
			if (mc != null) this.mc = mc;
			else this.mc = this;
			
			_clipMouseDown 						= this.mc;
			_clipMouseDown.abstractReponse 		= this;
			
			_spriteFocus = new Sprite();
			_colorShapeFocus = 0x000000;
		}
		
		public function set rollOver(value:Boolean):void 
		{
			if ( _rollOver != value) {
				_rollOver = value;
				
				if ( _rollOver) {
					mc.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
					mc.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
				}else {
					mc.removeEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
					mc.removeEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
				}
			}
		}
		
		public function get shapeFocus():Boolean { return _shapeFocus; }
		
		public function set shapeFocus(value:Boolean):void 
		{
			_shapeFocus = value;
		}
		public function onMouseOut(e:MouseEvent):void 
		{

		}
		
		public function onMouseOver(e:MouseEvent):void 
		{

			
		}
		public function hasLabel(label:String, clip:MovieClip = null):Boolean
		{
			
			var myClip:MovieClip = mc;
			if ( clip != null) myClip = clip; 
			var nbLabel:int = myClip.currentLabels.length;
			for (var i:int = 0; i < nbLabel; i++) 
			{
				if ( myClip.currentLabels[i].name == label) {
					return true;
					break;
				}
			}
			
			return false;
			
		}
		


	}
	
}